<template>
  <view class="page-container">
    <GlobalTopBar ref="topBarRef" class="topbars" :isLeft="true">
      <template #title><text>选择城市</text></template>
    </GlobalTopBar>
    <GlobalTopBar ref="topBarRef"> </GlobalTopBar>
    <view class="page_content">
      <city-select
        @cityClick="cityClick"
        :formatName="'areaname'"
        :obtainCitys="AllCityList"
        :isSearch="true"
      ></city-select>
    </view>
  </view>
</template>

<script setup>
import { ref, computed, reactive } from 'vue';
import { useCounterStore } from '@/store';
import { onLoad, onShow } from '@dcloudio/uni-app';
import request from '@/utils/request';
import { formatTimestamp } from '@/utils/validate';
import citySelect from '@/components/city-select/city-select.vue';

const store = useCounterStore();
const infoData = ref({});

const AllCityList = ref([]);
// 获取全国 市 级数据
const getAllCityList = async () => {
  const data = await request('wxapp/common/getAllCityList');
  AllCityList.value = data.list;
  // store.cityInfo = data.list[0];
};

const cityClick = (item) => {
  store.cityInfo = item;
  uni.navigateBack({
    delta: 1,
  });
};

onLoad((option) => {
  getAllCityList();
});
</script>

<style lang="scss" scoped>
.topbars {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  background-color: #ffffff;
}
.page_content {
  background-color: #fff;
  text-align: left;

  overflow-y: auto;
}
</style>
